Skip to content

fix(dashboard): fix WebUI dark mode rendering and multiple UI interaction bugs#7173

Merged
Soulter merged 3 commits intoAstrBotDevs:masterfrom
piexian:fix/dark-mode
Apr 8, 2026
Merged

fix(dashboard): fix WebUI dark mode rendering and multiple UI interaction bugs#7173
Soulter merged 3 commits intoAstrBotDevs:masterfrom
piexian:fix/dark-mode

Conversation

@piexian
Copy link
Copy Markdown
Contributor

@piexian piexian commented Mar 30, 2026

修复 WebUI 深色模式渲染问题及多个UI交互bug。

深色模式:当前深色模式仅是在浅色界面上覆盖了一层深色背景,导致大量组件文字、背景色、代码高亮等在深色模式下对比度极低、几乎不可见。此 PR 全面修复了深色主题的颜色体系,使深色模式真正可用。

语言切换:右上角语言切换菜单点击后立即关闭,移动端用户无法切换语言。

登录页主题切换:登录页面的主题切换按钮 tooltip 始终显示"切换到浅色主题",未根据当前主题状态动态切换文案和图标。

Modifications / 改动点

语言切换菜单修复:

  • VerticalHeader.vue:为语言菜单添加 v-model 控制和 @click.stop 阻止冒泡,启用 open-on-click,解决点击后菜单立即关闭导致移动端无法切换语言的问题

登录页主题切换修复:

  • LoginPage.vue:修复主题切换按钮的 tooltip 文案和图标根据当前主题状态动态显示

主题色彩体系重构:

  • DarkTheme.ts:重新调整深色主题全部颜色变量,包括 primary、surface、background、on-surface-variant、primaryText 等,确保深色模式下具有良好的对比度和可读性

代码高亮深色适配:

  • 新增 _HljsDark.scss:为 highlight.js 添加深色模式 token 颜色覆盖,并为 markstream-vue 的 CSS 变量在 .v-theme--PurpleThemeDark 下提供正确的深色值
  • style.scss:引入上述新样式文件

全局深色模式覆盖:

  • _override.scss:添加 .v-theme--PurpleThemeDark 全局覆盖规则,包括行内代码文字颜色(--astrbot-code-color)、flat 按钮透明度、timeline 节点、dialog/card 背景色、markdown 链接颜色等

组件级修复(移除硬编码浅色值):

  • TotalMessage.vueOnlinePlatform.vueRunningTime.vueMemoryUsage.vue:统计卡片添加深色模式专属背景色
  • ConsoleDisplayer.vue:降低 ANSI 终端颜色饱和度,适配深色背景
  • VerticalSidebar.vue:iframe 深色模式通过 CSS invert 滤镜适配
  • 多个组件移除硬编码的 color="black"bg-color="white" 等浅色写死值,改用主题变量

涉及的其他组件文件:

  • IPythonToolBlock.vueExtensionCard.vueT2ITemplateEditor.vueExtensionPage.vueKnowledgeBase.vueLongTermMemory.vuePlatformStat.vueProviderPage.vuePlatformPage.vuePersonaPage.vue

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

PixPin_2026-03-30_11-25-47.mp4
Screenrecorder-2026-03-30-12-00-17-613.mp4

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了"验证步骤"和"运行截图"

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txt 和 pyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Improve dashboard dark theme usability and fix several WebUI visual and interaction issues.

Bug Fixes:

  • Fix language-switcher menu so it remains usable on mobile and closes only after a language is selected.
  • Correct login page theme toggle tooltip text and icon to reflect the current theme state.

Enhancements:

  • Refine the global dark color palette and component backgrounds for better contrast and readability across the dashboard.
  • Adjust embedded iframe, cards, graphs, and markdown content to respect dark mode styling instead of hard-coded light colors.
  • Tweak console ANSI color mapping and code/markdown highlight styles for better legibility in dark mode.

- Tune DarkTheme.ts color palette: soften primary, fix on-surface-variant
  from black to light grey, adjust surface/background/border colors,
  add codeBg/preBg/code variables for dark code blocks
- Add _HljsDark.scss for highlight.js dark token overrides and
  markstream-vue CSS variable overrides under .v-theme--PurpleThemeDark
- Add global dark mode overrides in _override.scss: soften flat primary
  buttons, timeline dots, dialog card backgrounds, markdown link color
- Fix hardcoded light backgrounds in IPythonToolBlock, ExtensionCard,
  T2ITemplateEditor, ExtensionPage, KnowledgeBase, LongTermMemory
- Remove hardcoded color='black' from icons in ProviderPage,
  PlatformPage, PersonaPage
- Desaturate console log ANSI colors for dark mode readability
- Add iframe dark mode inversion filter in VerticalSidebar
- Fix language switcher mobile adaptation and click behavior
- Fix login page theme toggle tooltip showing wrong label
@auto-assign auto-assign bot requested review from Soulter and anka-afk March 30, 2026 04:04
Copilot AI review requested due to automatic review settings March 30, 2026 04:04
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 30, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In VerticalSidebar.vue the isMobile flag is computed once from window.innerWidth and never updated; consider making this reactive (e.g., a ref with a resize listener) so layout/iframe behavior stays correct when the viewport is resized.
  • Many dark-mode colors (e.g., #1e1e2e, #1a1a2e, #2a2a2a, #6cb6ff, #ddd, #aaa) are now hard-coded across multiple components and styles; it would be more maintainable to centralize these as theme variables or SCSS variables to avoid drift and simplify future theme changes.
  • The iframeStyle/dragHeaderStyle and related inline style bindings in VerticalSidebar.vue are fairly complex; extracting these into CSS classes (with conditional classes for dark mode) would make the template easier to read and reduce the amount of style logic in the script.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `VerticalSidebar.vue` the `isMobile` flag is computed once from `window.innerWidth` and never updated; consider making this reactive (e.g., a `ref` with a resize listener) so layout/iframe behavior stays correct when the viewport is resized.
- Many dark-mode colors (e.g., `#1e1e2e`, `#1a1a2e`, `#2a2a2a`, `#6cb6ff`, `#ddd`, `#aaa`) are now hard-coded across multiple components and styles; it would be more maintainable to centralize these as theme variables or SCSS variables to avoid drift and simplify future theme changes.
- The `iframeStyle`/`dragHeaderStyle` and related inline style bindings in `VerticalSidebar.vue` are fairly complex; extracting these into CSS classes (with conditional classes for dark mode) would make the template easier to read and reduce the amount of style logic in the script.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the area:webui The bug / feature is about webui(dashboard) of astrbot. label Mar 30, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly refines the dark mode implementation across the dashboard by updating the PurpleThemeDark color palette and adding theme-specific styles for various components, including the sidebar, knowledge base, and code highlighting. Key changes include refactoring the draggable iframe in the sidebar to be theme-aware and improving the language switcher's behavior. The review feedback consistently highlights the use of hardcoded hex color values in several components and SCSS files, suggesting they be replaced with Vuetify theme variables or CSS variables from DarkTheme.ts to improve maintainability and UI consistency.


.code-fallback.dark-theme {
background-color: transparent;
background-color: #1e1e2e;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了保持主题一致性和可维护性,建议将硬编码的颜色值 #1e1e2e 替换为 Vuetify 主题变量。例如 rgb(var(--v-theme-surface))

如果这个颜色在多处使用且与现有主题变量都不同,最好在 src/theme/DarkTheme.ts 中将其定义为一个新的颜色变量,然后在所有使用到的地方统一调用。

此建议同样适用于第 181 行。

    background-color: rgb(var(--v-theme-surface));

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the dashboard WebUI’s dark mode usability and fixes multiple UI interaction issues (notably language switching behavior and login-page theme toggle feedback).

Changes:

  • Refactors the PurpleThemeDark color palette and adds global dark-mode overrides to improve contrast/readability.
  • Fixes language menu interaction in the top header (mobile click behavior) and closes the main menu after switching language.
  • Adjusts code highlighting styling by switching to highlight.js light theme + scoped dark overrides, and updates several components to better support dark mode.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
dashboard/src/views/authentication/auth/LoginPage.vue Makes theme toggle icon/tooltip reflect current theme state.
dashboard/src/layouts/full/vertical-header/VerticalHeader.vue Updates language menu behavior and menu open state handling.
dashboard/src/layouts/full/vertical-sidebar/VerticalSidebar.vue Improves iframe styling/drag behavior and dark-mode appearance.
dashboard/src/theme/DarkTheme.ts Updates the dark theme color system for better contrast.
dashboard/src/scss/style.scss Imports new highlight.js dark override stylesheet.
dashboard/src/scss/components/_HljsDark.scss Adds dark-mode highlight.js token overrides and markstream-vue variable overrides.
dashboard/src/scss/_override.scss Adds global dark-mode overrides (code color, buttons, dialogs/cards, links).
dashboard/src/components/shared/ReadmeDialog.vue Switches highlight.js base theme to github.css (light) for dual-mode support.
dashboard/src/components/shared/ConsoleDisplayer.vue Tweaks ANSI color mapping for better legibility on dark backgrounds.
dashboard/src/components/chat/message_list_comps/IPythonToolBlock.vue Adjusts dark-theme backgrounds for code/result areas.
dashboard/src/views/alkaid/LongTermMemory.vue Adds dark-mode-specific backgrounds for graph container and details.
dashboard/src/views/alkaid/KnowledgeBase.vue Removes hardcoded light background; adds dark-mode styles for KB cards.
dashboard/src/views/ExtensionPage.vue Adds dark-mode background for plugin handler items.
dashboard/src/components/shared/T2ITemplateEditor.vue Adds dark-mode background for preview container.
dashboard/src/components/shared/ExtensionCard.vue Adjusts dark-mode card colors/opacity.
dashboard/src/views/ProviderPage.vue Removes hardcoded black icon color to allow theme-driven coloring.
dashboard/src/views/PlatformPage.vue Removes hardcoded black icon color to allow theme-driven coloring.
dashboard/src/views/PersonaPage.vue Removes hardcoded black icon color to allow theme-driven coloring.

@Soulter Soulter changed the title fix(dashboard): 修复 WebUI 深色模式渲染问题及多个UI交互bug fix(dashboard): fix WebUI dark mode rendering and multiple UI interaction bugs Apr 6, 2026
@Soulter
Copy link
Copy Markdown
Member

Soulter commented Apr 6, 2026

@piexian 可以参考 cr 给出的相关建议,使用 vuetify 变量替代硬编码颜色值

@piexian
Copy link
Copy Markdown
Contributor Author

piexian commented Apr 6, 2026

@piexian 可以参考 cr 给出的相关建议,使用 vuetify 变量替代硬编码颜色值

👌

@piexian
Copy link
Copy Markdown
Contributor Author

piexian commented Apr 6, 2026

@piexian 可以参考 cr 给出的相关建议,使用 vuetify 变量替代硬编码颜色值

改好了测试没问题你看看这样行不

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 8, 2026
@Soulter Soulter merged commit 2020eec into AstrBotDevs:master Apr 8, 2026
7 checks passed
@piexian piexian deleted the fix/dark-mode branch April 8, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants